import os
import sys
import json
import django
import datetime

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
print(BASE_DIR)
sys.path.extend([BASE_DIR, ])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "finance_c2c.settings")

django.setup()
from apps.coffee.models import BankExchangeCode, Channel
from core.tools.func_utils import unique_code


def coupon_manager(quota, num, name, c_type=2):
    """
    :param quota:
    :param num:
    :param name:
    :param c_type: 2 立减券
    :return:
    """
    l = []
    channel = Channel.objects.get(key="meiwei")
    for i in range(200):
        code = "M"+unique_code()
        l.append(BankExchangeCode(
            code=code,
            bank="美味不用等",
            num=num,
            quota=quota,
            name=name,
            channel=channel,
            c_type=c_type,
            expire_time=datetime.datetime(2022, 7, 31)
        ))
    BankExchangeCode.objects.bulk_create(l)

if __name__ == '__main__':
    coupon_manager(1300, 2, "11元立减券")
